# Contributor: Jeremy Thomerson <jeremy@thomersonfamily.com>
# Maintainer: Jeremy Thomerson <jeremy@thomersonfamily.com>
pkgname=librsync
pkgver=2.3.2
pkgrel=2
pkgdesc="librsync implements the rolling-checksum algorithm of rsync"
url="https://github.com/librsync/librsync"
arch="all"
license="LGPL-2.1-or-later"
makedepends="cmake popt-dev bzip2-dev zlib-dev perl samurai"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/librsync/librsync/archive/v$pkgver.tar.gz
	"

prepare() {
	default_prepare
	# don't invoke bash in test scripts
	sed -i 's,#! /bin/bash,#!/bin/sh,' tests/rdiff_bad_option.sh
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -D -m644 doc/rdiff.1 "$pkgdir/usr/share/man/man1/rdiff.1"
	install -D -m644 doc/librsync.3 "$pkgdir/usr/share/man/man3/librsync.3"
}

sha512sums="
77d826dbaf02061b759d876a6b537238bad40379a08e4494ebfd3e380b2eb921b7b060bc570330aeac9424ef1a9d521f449d559c9ffa3be24acdef4ad530fe90  librsync-2.3.2.tar.gz
"
